package com.ATMgui;

import com.lovo.util.Util;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Menu extends JPanel implements ActionListener {
    private Icon quqian = Util.getIcon("/image/buttonGet.jpg");

    private Icon cunkuan = Util.getIcon("/image/buttonSave.jpg");
    private Icon chaxun = Util.getIcon("/image/buttonFind.jpg");
    private Icon exit = Util.getIcon("/image/buttonOff.jpg");
    private ATM frame;
    private JButton tuichu = new JButton();

    public Menu(ATM frame) {
        this.frame = frame;
        this.setLayout(null);

        this.setOpaque(false);
        JButton quqianBtn = new JButton(quqian);
        quqianBtn.setBounds(200, 320, 100, 20);
        this.add(quqianBtn);

        this.setOpaque(false);
        JButton cunkuanBtn = new JButton(cunkuan);
        cunkuanBtn.setBounds(400, 320, 100, 20);
        this.add(cunkuanBtn);

        this.setOpaque(false);
        JButton chaxunBtn = new JButton(chaxun);
        chaxunBtn.setBounds(200, 340, 100, 20);
        this.add(chaxunBtn);

        this.setOpaque(false);
        tuichu = new JButton(exit);
        tuichu.setBounds(400, 340, 100, 20);
        this.add(tuichu);
        tuichu.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == tuichu) {
            frame.switchPanel("登陆");
        }
    }
}
